package com.ruoyi.business.service;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.bizsys.domain.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author: Jamnsin
 * @Date: 2021/6/15 11:49 下午
 */
public interface IRepaymentService {

    void repayment(RepaymentOrder repaymentOrder);

    void repaymentNoLock(RepaymentOrder repaymentOrder);

    void repaymentNoLockForDefer(RepaymentOrder repaymentOrder);

    /**
     * @param loanIou
     * @param repaymentSn
     * @param actionType
     * @param amt
     * @param reduceFee
     * @param type        repaymentSn 参数类型   1还款流水号   2减免流水号
     */
    void repayment(LoanIou loanIou, String repaymentSn, String actionType, BigDecimal amt, BigDecimal reduceFee, int type);

    void repaymentNoLock(LoanIou loanIou, String repaymentSn, String actionType, BigDecimal amt, BigDecimal reduceFee, int type);

    RepaymentOrder getMaxSuccessDate(String loanSerialNo);

    JSONObject repaymentTrial(JSONObject params,LoanIou loanIou);

    JSONObject repaymentTrialDeferred(JSONObject params);

    void doReduceAmtStrike(RepaymentOrder r);

    boolean createRepaymentOrderAndPayTrans(String serialNo, CustBankCard bankCard, String reduceFlag);

    RepaymentOrder doCollectionRepaymentAction(LoanIou loanIou, CreditAccount creditAccount, CustBankCard bankCard, BigDecimal realActAmt);

    /**
     * MQ 监听主动还款
     *
     * @return
     */
    void selfRepaymentForMqListener(RepaymentOrder repaymentOrder);

    /**
     * 延期还款
     *
     * @param repaymentOrder
     * @param creditAccount
     */
    void selfDeFerRepaymentForMqListener(RepaymentOrder repaymentOrder, CreditAccount creditAccount);

    RepaymentOrder initRepaymentOrderFromLoanIou(LoanIou loanIou, String actionType, BigDecimal amount);

    List<RepaymentOrder> getToActionTypeAndLoanSerialNo(String actionType, String loanSerialNo);

    JSONObject creatPayOrder(JSONObject jsonObject);
    boolean createRepaymentOrderAndPayTransForDefer(String serialNo, CustBankCard bankCard, LoanDeferredOrder loanDeferredOrder);


    /**
     * 延期还款，-钱包刚好足够全额还款
     *
     * @param loanIou
     */
    void selfDeFerWalletRepaymentForMqListener(LoanIou loanIou, RepaymentOrder repaymentOrder);

    /**
     * 钱包延期还款还部分
     *
     * @param loanDeferredOrder
     * @return
     */
    boolean createRepaymentOrderForDeferBfWallet(LoanDeferredOrder loanDeferredOrder, BigDecimal amtWallet, String walletNo, LoanIou loanIou);

    /**
     * @param loanIou
     * @param bankCard
     * @param loanDeferredOrder
     * @param productDeferredInfo
     * @return
     */
    boolean createRepaymentOrderAndPayTransForDeferNoSuccess(String walletNo,BigDecimal minPay, LoanIou loanIou, CustBankCard bankCard, LoanDeferredOrder loanDeferredOrder, ProductDeferredInfo productDeferredInfo);

    /**
     * 延期+钱包+部分钱包还款
     *
     * @param repaymentOrder
     * @param creditAccount
     */
    void selfDeFerNotAllRepaymentForMqListener(RepaymentOrder repaymentOrder, CreditAccount creditAccount);

    /**
     * 全额还款+钱包全部还款
     *
     * @param loanIou
     * @param repaymentOrder
     */
    void selfWalletRepaymentForMqListener(LoanIou loanIou, RepaymentOrder repaymentOrder);

    RepaymentOrder createRepaymentOrderForfWalletNotAll(String actionType,BigDecimal amtWallet, String walletNo, LoanIou loanIou);

    boolean createRepaymentOrderAndPayTransForNoSuccess(BigDecimal paystaskAmt, LoanIou loanIou, CustBankCard bankCard, String walletNo);

    void selfNotAllRepaymentForMqListener(RepaymentOrder repaymentOrder, long creditAccountId);
}
